home *** CD-ROM | disk | FTP | other *** search
- unit OneToManyClient2U;
-
- interface
-
- uses
- Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- Db, DBClient, MConnect, Grids, DBGrids, ActnList, StdCtrls;
-
- type
- TClientForm = class(TForm)
- cdsCustomer: TClientDataSet;
- dcOneToManyServer: TDCOMConnection;
- DataSource1: TDataSource;
- DBGrid1: TDBGrid;
- CheckBox1: TCheckBox;
- ActionList1: TActionList;
- actShowPopupGrid: TAction;
- procedure FormCreate(Sender: TObject);
- procedure actShowPopupGridExecute(Sender: TObject);
- procedure actShowPopupGridUpdate(Sender: TObject);
- private
- FPopupGrid: TCustomDBGrid;
- end;
-
- var
- ClientForm: TClientForm;
-
- implementation
-
- {$R *.DFM}
-
- procedure TClientForm.FormCreate(Sender: TObject);
- var
- I: Integer;
- Pt: TPoint;
- Col: TColumn;
- begin
- cdsCustomer.Open;
- //Locate and hide dataset field column
- Col := nil;
- for I := 0 to DBGrid1.Columns.Count - 1 do
- if DBGrid1.Columns[I].Field is TDataSetField then
- begin
- Col := DBGrid1.Columns[I];
- Col.Visible := False;
- Break //There is one dataset field column
- end;
- if not Assigned(Col) then
- raise EDatabaseError.Create(
- 'Trouble brewing... dataset field not found');
- //Display popup grid below other grid
- Pt := Point(DBGrid1.Left, DBGrid1.Top + DBGrid1.Height);
- Pt := ClientToScreen(Pt);
- DBGrid1.ShowPopupEditor(Col, Pt.X, Pt.Y);
- //Because the popup grid has been displayed,
- //it remains in existence with the main grid, so
- //save reference to it for later use
- for I := 0 to DBGrid1.ComponentCount - 1 do
- if DBGrid1.Components[I] is TCustomDBGrid then
- FPopupGrid := TCustomDBGrid(DBGrid1.Components[I]);
- if not Assigned(FPopupGrid) then
- raise EDatabaseError.Create(
- 'Trouble brewing... popup grid not found')
- end;
-
- procedure TClientForm.actShowPopupGridExecute(Sender: TObject);
- begin
- FPopupGrid.Visible := not actShowPopupGrid.Checked
- end;
-
- procedure TClientForm.actShowPopupGridUpdate(Sender: TObject);
- begin
- actShowPopupGrid.Checked := FPopupGrid.Visible
- end;
-
- end.
-